home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 January: Mac OS SDK / Dev.CD Jan 96 SDK / Dev.CD Jan 96 SDK1.toast / Development Kits (Disc 1) / QuickDraw™ GX / Programming Stuff / Sample Code / Graphics Samples / Text To Outlines ƒ / Text To Outlines.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-10  |  3.6 KB  |  129 lines  |  [TEXT/KAHL]

  1. /**
  2.     Text To Outlines.c
  3.     
  4.     This application will create a gxLine of text, and convert it to a gxPath gxShape. By changing the
  5.     sample to a gxPath will give you the outlines of each character. 
  6.     
  7.     
  8.     NOTES:
  9.     • This file requires the following files to run correctly:
  10.         "graphics shell.c", "Font library.c", "graphics debug library.c", "Transform library.c".
  11.  
  12.     • This file prints the "best" in landscape mode.
  13.     
  14.     ©1990-1994  Apple Computer, Inc.
  15.     All rights reserved.
  16. **/
  17.  
  18. #include <Events.h>
  19. #include <Windows.h>
  20.  
  21. #include "graphics libraries.h"
  22. #include "graphics toolbox.h"
  23. #include "Font library.h"
  24. #include "graphics shell.h"
  25.  
  26.  
  27. //
  28. //  Set up the title and size of the window 
  29. //
  30. Str255         gWindowTitle = "\p Text To Outlines ";         
  31. Rect         gWindowQDRect  = {50, 10, 280, 460};
  32.  
  33. //
  34. //    gGraphicsHeapSize sets the size of the graphics gxHeap created by calling the GXNewGraphicsClient routine
  35. //    in main () within graphics shell.c.  You can determine the amount of graphics gxHeap required by using GraphicsBug.
  36. //    With  gGraphicsHeapSize set to 15k, I had 4 free blocks left in the graphics gxHeap. Sounds good to me.
  37. //
  38. long        gGraphicsHeapSize = 75;
  39.  
  40. gxShape         gTextOutlineShape;
  41.  
  42.  
  43.  
  44. /*------ DoInitialization ---------------------------------------------------------------------------------*/
  45.  
  46. void DoInitialization(aWindow)
  47. WindowPtr aWindow;
  48. {
  49.     gxPoint    textPostion;
  50.     gxColor     textOutlineColor;
  51.     
  52.     //
  53.     //    Set up the starting text postion. This location will be set up when we
  54.     //    create our text gxShape.
  55.     //
  56.     textPostion.x = ff(30);
  57.     textPostion.y = ff(150);
  58.     
  59.     //
  60.     //  Create the text, and set the gxFont and size.
  61.     //
  62.     gTextOutlineShape = GXNewText(5,(unsigned char*)"Waves", &textPostion);
  63.     SetShapeCommonFont(gTextOutlineShape, timesFont);
  64.     GXSetShapeTextSize(gTextOutlineShape, ff(145));
  65.  
  66.     GXSetShapeType(gTextOutlineShape, gxPathType);
  67.     GXSetShapeFill(gTextOutlineShape, gxClosedFrameFill);
  68.     GXSetShapePen(gTextOutlineShape, ff(2));
  69.     GXSetShapeStyleAttributes(gTextOutlineShape, gxOutsideFrameStyle);
  70.  
  71.     
  72.     //
  73.     //    A gxColor, to run through hsv space with... 
  74.     //
  75.     textOutlineColor.space                     = gxHSVSpace;
  76.     textOutlineColor.profile                 = nil;
  77.     textOutlineColor.element.hsv.hue         = 0xD4DA;
  78.     textOutlineColor.element.hsv.saturation = 0xD657;
  79.     textOutlineColor.element.hsv.value         = 0xFFFF;
  80.  
  81.     GXSetShapeColor(gTextOutlineShape, &textOutlineColor);
  82. }
  83.  
  84.  
  85.  
  86. /*------ DoDraw ---------------------------------------------------------------------------------------*/
  87.  
  88. void DoDraw(aWindow)
  89. WindowPtr aWindow;
  90. {
  91.     GXDrawShape (gTextOutlineShape);
  92. }
  93.  
  94.  
  95. /*------ DoDispose -------------------------------------------------------------------------------------*/
  96.  
  97. void DoDispose(aWindow)
  98. WindowPtr aWindow;
  99. {
  100.     //  
  101.     //    You should always dispose of your GX graphics objects before tossing your window. Why? It's generally good 
  102.     //    form and this approach guarantees that everything is disposed. If you had not disposed of everything, the
  103.     //    call to DisposeWindow should dispose of the objects. If you are running the debugging version of the 
  104.     //    SecretGraphics init with notices set, you will receive a notice that you had not disposed of everything. You
  105.     //    can turn notices on in this file by setting gDebugging = TRUE (above).
  106.     //
  107.     GXDisposeShape(gTextOutlineShape);  
  108.     GXDisposeShape(gWindowBoundsShape);  
  109.        DisposeWindow(aWindow);
  110. }
  111.     
  112.  
  113.  
  114. /*------ DoClick ---------------------------------------------------------------------------------------*/
  115.  
  116. void DoClick( orgMouseLoc, theWindow )
  117. gxPoint        orgMouseLoc;
  118. WindowPtr     theWindow;
  119. {
  120. }
  121.  
  122.  
  123. /*------ DoIdle ----------------------------------------------------------------------------------------*/
  124.  
  125. void DoIdle(aWindow)
  126. WindowPtr aWindow;
  127. {
  128. }
  129.